home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MPW Oberon 2.1168 / OExamples / TESample.h < prev    next >
Encoding:
Text File  |  1993-05-07  |  9.9 KB  |  243 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware TextEdit Sample Application
  6. #
  7. #    TESample
  8. #
  9. #    TESample.h    -    Rez and C Include Source
  10. #
  11. #    Copyright © Apple Computer, Inc. 1989-1990
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                08/88
  16. #                1.01                11/88
  17. #                1.02                04/89    MPW 3.1
  18. #                1.03                02/90    MPW 3.2
  19. #
  20. #    Components:
  21. #                TESample.p            Feb.  1, 1990
  22. #                TESampleGlue.a        Feb.  1, 1990
  23. #                TESample.r            Feb.  1, 1990
  24. #                TESample.h            Feb.  1, 1990
  25. #                TESample.make        Feb.  1, 1990
  26. #
  27. #    TESample is an example application that demonstrates how 
  28. #    to initialize the commonly used toolbox managers, operate 
  29. #    successfully under MultiFinder, handle desk accessories and 
  30. #    create, grow, and zoom windows. The fundamental TextEdit 
  31. #    toolbox calls and TextEdit autoscroll are demonstrated. It 
  32. #    also shows how to create and maintain scrollbar controls.
  33. #
  34. #    It does not by any means demonstrate all the techniques you 
  35. #    need for a large application. In particular, Sample does not 
  36. #    cover exception handling, multiple windows/documents, 
  37. #    sophisticated memory management, printing, or undo. All of 
  38. #    these are vital parts of a normal full-sized application.
  39. #
  40. #    This application is an example of the form of a Macintosh 
  41. #    application; it is NOT a template. It is NOT intended to be 
  42. #    used as a foundation for the next world-class, best-selling, 
  43. #    600K application. A stick figure drawing of the human body may 
  44. #    be a good example of the form for a painting, but that does not 
  45. #    mean it should be used as the basis for the next Mona Lisa.
  46. #
  47. #    We recommend that you review this program or Sample before 
  48. #    beginning a new application. Sample is a simple app. which doesn’t 
  49. #    use TextEdit or the Control Manager.
  50. #
  51. ------------------------------------------------------------------------------*/
  52.  
  53. /*    These #defines correspond to values in the Pascal source code.
  54.     TESample.c and TESample.r include this file. */
  55.  
  56. /*    Determining an application's minimum size to request from MultiFinder depends
  57.     on many things, each of which can be unique to an application's function,
  58.     the anticipated environment, the developer's attitude of what constitutes
  59.     reasonable functionality and performance, etc. Here is a list of some things to
  60.     consider when determining the minimum size (and preferred size) for your
  61.     application. The list is pretty much in order of importance, but by no means
  62.     complete.
  63.     
  64.     1.    What is the minimum size needed to give almost 100 percent assurance
  65.         that the application won't crash because it ran out of memory? This
  66.         includes not only things that you do have direct control over such as
  67.         checking for NIL handles and pointers, but also things that some
  68.         feel are not so much under their control such as QuickDraw and the
  69.         Segment Loader.
  70.         
  71.     2.    What kind of performance can a user expect from the application when
  72.         it is running in the minimum memory configuration? Performance includes
  73.         not only speed in handling data, but also things like how many documents
  74.         can be opened, etc.
  75.         
  76.     3.    What are the typical sizes of scraps is [a boy dog] that a user might
  77.         wish to work with when lauching or switching to your application? If
  78.         the amount of memory is too small, the scrap may get lost [will have
  79.         to be shot]. This can be quite frustrating to the user.
  80.         
  81.     4.    The previous items have concentrated on topics that tend to cause an
  82.         increase in the minimum size to request from MultiFinder. On the flip
  83.         side, however, should be the consideration of what environments the
  84.         application may be running in. There may be a high probability that
  85.         many users with relatively small memory configurations will want to
  86.         avail themselves of your application. Or, many users might want to use it
  87.         while several other, possibly related/complementary applications are
  88.         running. If that is the case, it would be helpful to have a fairly
  89.         small minimum size.
  90.     
  91.     What we did for TESample:
  92.     
  93.         We determined the smallest heap size that TESample could have and still
  94.         run (22K). For the preferred size we added enough space to permit:
  95.             a. a maximum size TextEdit text handle (32000 characters)
  96.             b. a maximum usable TextEdit scrap (32000 characters)
  97.             b. a maximum scrap as a result of Copy (32000 characters)
  98.             d. a little performance cushion (see 2, above) (10K)
  99.         Result: 122K for preferred size
  100.         
  101.         For the minimum size we took the 22K and then scaled down our requirements
  102.         for a,b, and c above. We thought that providing 16K more would be lean
  103.         and mean (see 4, above).
  104.         Result: 38K for minimum size
  105. */
  106.  
  107. #define kPrefSize                122
  108. #define kMinSize                38
  109.     
  110. /* The following constants are used to identify menus and their items. The menu IDs
  111.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  112. #define    mApple                    128        /* Apple menu */
  113. #define    iAbout                    1
  114.  
  115. #define    mFile                    129        /* File menu */
  116. #define    iNew                    1
  117. #define    iClose                    4
  118. #define    iQuit                    12
  119.  
  120. #define    mEdit                    130        /* Edit menu */
  121. #define    iUndo                    1
  122. #define    iCut                    3
  123. #define    iCopy                    4
  124. #define    iPaste                    5
  125. #define    iClear                    6
  126.  
  127. /*    1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */
  128.  
  129. #define kDITop                    0x0050
  130. #define kDILeft                    0x0070
  131.  
  132. /* 1.01 - changed constants to begin with 'k' for consistency, except for resource IDs */
  133. /*    kTextMargin is the number of pixels we leave blank at the edge of the window. */
  134. #define kTextMargin                2
  135.  
  136. /* kMaxOpenDocuments is used to determine whether a new document can be opened
  137.    or created. We keep track of the number of open documents, and disable the
  138.    menu items that create a new document when the maximum is reached. If the
  139.    number of documents falls below the maximum, the items are enabled again. */
  140. #define    kMaxOpenDocuments        1
  141.     
  142. /*    kMaxDocWidth is an arbitrary number used to specify the width of the TERec's
  143.     destination rectangle so that word wrap and horizontal scrolling can be
  144.     demonstrated. */
  145. #define    kMaxDocWidth            576
  146.     
  147. /* kMinDocDim is used to limit the minimum dimension of a window when GrowWindow
  148.     is called. */
  149. #define    kMinDocDim                64
  150.  
  151. /*    kControlInvisible is used to 'turn off' controls (i.e., cause the control not
  152.     to be redrawn as a result of some Control Manager call such as SetCtlValue)
  153.     by being put into the contrlVis field of the record. kControlVisible is used
  154.     the same way to 'turn on' the control. */
  155. #define kControlInvisible        0
  156. #define kControlVisible            0xFF
  157.  
  158. /*    kScrollbarAdjust and kScrollbarWidth are used in calculating
  159.     values for control positioning and sizing. */
  160. #define kScrollbarWidth            16
  161. #define kScrollbarAdjust        (kScrollbarWidth - 1)
  162.  
  163. /*    kScrollTweek compensates for off-by-one requirements of the scrollbars
  164.  to have borders coincide with the growbox. */
  165. #define kScrollTweek            2
  166.     
  167. /*    kCrChar is used to match with a carriage return when calculating the
  168.     number of lines in the TextEdit record. kDelChar is used to check for
  169.     delete in keyDowns. */
  170. #define kCrChar                    13
  171. #define kDelChar                8
  172.     
  173. /*    kButtonScroll is how many pixels to scroll horizontally when the button part
  174.     of the horizontal scrollbar is pressed. */
  175. #define kButtonScroll            4
  176.     
  177. /*    kMaxTELength is an arbitrary number used to limit the length of text in the TERec
  178.     so that various errors won't occur from too many characters in the text. */
  179. #define    kMaxTELength            32000
  180.  
  181. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  182.    SysEnvRec we understand. */
  183. #define    kSysEnvironsVersion        1
  184.  
  185. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  186.    by MultiFinder. Once we determine that an event is an OSEvent, we look at the
  187.    high byte of the message sent to determine which kind it is. To differentiate
  188.    suspend and resume events we check the resumeMask bit. */
  189. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  190. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  191. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  192. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  193. #define    kNoEvents                0        /* no events mask */
  194.  
  195. /* 1.01 - kMinHeap - This is the minimum result from the following
  196.      equation:
  197.             
  198.             ORD(GetApplLimit) - ORD(ApplicZone)
  199.             
  200.      for the application to run. It will insure that enough memory will
  201.      be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  202.      application, and still give the application some 'breathing room'.
  203.      To derive this number, we ran under a MultiFinder partition that was
  204.      our requested minimum size, as given in the 'SIZE' resource. */
  205.      
  206. #define    kMinHeap                 (29 * 1024)
  207.     
  208. /* 1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called
  209.      at initialization time, for the application to run. This number acts
  210.      as a double-check to insure that there really is enough memory for the
  211.      application to run, including what has been taken up already by
  212.      pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  213.      
  214. #define    kMinSpace                (20 * 1024)
  215.  
  216. /*    kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  217. #define kExtremeNeg                -32768
  218. #define kExtremePos                (32767 - 1)    /* required to address an old region bug */
  219.     
  220. /* kTESlop provides some extra security when pre-flighting edit commands. */
  221. #define    kTESlop                    1024
  222.  
  223. /* The following are indicies into STR# resources. */
  224. #define    eWrongMachine            1
  225. #define    eSmallSize                2
  226. #define    eNoMemory                3
  227. #define    eNoSpaceCut                4
  228. #define    eNoCut                    5
  229. #define    eNoCopy                    6
  230. #define    eExceedPaste            7
  231. #define    eNoSpacePaste            8
  232. #define    eNoWindow                9
  233. #define    eExceedChar                10
  234. #define    eNoPaste                11
  235.  
  236. #define    rMenuBar    128                /* application's menu bar */
  237. #define    rAboutAlert    128                /* about alert */
  238. #define    rUserAlert    129                /* user error alert */
  239. #define    rDocWindow    128                /* application's window */
  240. #define    rVScroll    128                /* vertical scrollbar control */
  241. #define    rHScroll    129                /* horizontal scrollbar control */
  242. #define    kErrStrings    128                /* error string list */
  243.